/**
 * ------------------------------------------------------------*
 *          COPYRIGHT (C) 2006 BOCO Inter-Telecom INC          *
 *   CONFIDENTIAL AND PROPRIETARY. ALL RIGHTS RESERVED.        *
 *                                                             *
 *  This work contains confidential business information       *
 *  and intellectual property of BOCO  Inc, Beijing, CN.       *
 *  All rights reserved.                                       *
 * ------------------------------------------------------------*
 *
 *
 */
/**
 *Revision Information:
 *
 *@version 1.0 2006-3-21 release(zhanglei)
 */

package com.boco.webmaster.model;

import java.util.*;
import com.boco.transnms.server.bo.misc.EnumBO;
import com.boco.transnms.client.model.base.IBoCommand;
import com.boco.transnms.client.model.base.BoCmdFactory;
import com.boco.transnms.server.bo.helper.misc.EnumBOHelper;
import com.boco.common.util.lang.GenericEnum;

public class SiteTypeModel {
    private static SiteTypeModel instance = new SiteTypeModel();
    private Map siteTypeMap = new HashMap();
    public SiteTypeModel() {
        refresh();
    }

    public void refresh(){
        String enmuName = EnumBO.EnumName.SITE_CFG_TYPE;
        IBoCommand cmd = BoCmdFactory.getInstance().createBoCmd(EnumBOHelper.ActionName.getEnum, new Object[] {enmuName});
        GenericEnum siteType = (GenericEnum) cmd.exec();
        String[] siteTypeEnum = siteType.getAllNames();
        for (int i = 0; i < siteTypeEnum.length; i++) {
            siteTypeMap.put(siteType.getValue(siteTypeEnum[i]),siteTypeEnum[i]);
        }
    }

    public static SiteTypeModel getInstance(){
        return instance;
    }

    public String getValue(long key){
        return (String)siteTypeMap.get(key);
    }

    public long getValueByName(String label_cn){
        Iterator i = siteTypeMap.keySet().iterator();
        while (i.hasNext()) {
            Long cuid = (Long) i.next();
            String name = (String) siteTypeMap.get(cuid);
            if (name.equals(label_cn)) {
                return  cuid;
            }
        }
        return -1;
    }

    public void addsiteType(long key,String value) {
        siteTypeMap.put(key, value);
    }

    public void delsiteType(long key) {
        siteTypeMap.remove(key);
    }

    public void modifysiteType(long key,String value) {
        siteTypeMap.remove(key);
        siteTypeMap.put(key, value);
    }
}
